<template>
  <div>
    <div class="box">应用下载</div>
    <div class="bady">
      <el-input
        v-model="queryParams.softName"
        placeholder="请输入内容"
        clearable
        size="medium"
        max="5"
        @keyup.enter.native="handleQuery"
      ></el-input>
      <el-button
        style="margin-left: 8px"
        type="primary"
        icon="el-icon-search"
        size="medium "
        @click="handleQuery"
        >搜索</el-button
      >
    </div>
    <!-- 检测软件 -->
    <div class="bottn">
      <div class="buttnLink" v-for="(item, index) in softName" :key="index">
        <div style="height: 20%">{{ item.softName }}</div>
        <div style="height: 60%">{{ item.description }}</div>
        <div class="buttonRoom">
          <div class="left">
            <el-link
              type="primary"
              @click="handleMoos"
              v-hasPermi="['system:post:remove']"
              >查看详情>{{ item.approvalStatusText }}</el-link
            >
          </div>
          <div class="right">
            <el-row>
              <el-button type="primary">下载 {{ item.roleIds }}</el-button>
            </el-row>
          </div>
        </div>
      </div>
    </div>
    <!-- 下载版本 -->
    <el-dialog
      title="版本下载"
      :visible.sync="open"
      v-for="(item, index) in softName"
      :key="index"
      width:100
    >
      <!-- 名称 -->
      <div style="text-align: center; font-size: 20px">{{ item.softName }}</div>
      <!-- 描述 -->
      <div style="">{{ item.description }}</div>
      <el-table :data="gridData">
        <el-table-column
          prop="version"
          label="版本"
          align="center"
        ></el-table-column>
        <el-table-column
          prop="postName"
          label="文件大小"
          align="center"
        ></el-table-column>
        <el-table-column
          align="center"
          prop="postName"
          label="URL"
        ></el-table-column>
        <el-table-column
          align="center"
          prop="postName"
          label="包说明"
        ></el-table-column>
      </el-table>
    </el-dialog>
  </div>
</template>
<script>
import { listApproval, delDashboard } from "@/api/serves/approval";
import { listVersion } from "@/api/serves/version";

export default {
  data() {
    return {
      input: "",
      softName: [],
      gridData: [],
      dialogTableVisible: false,
      open: false,
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        // postCode: undefined,
        softName: undefined,
        status: undefined,
        softManageId: undefined,
        // 版本号
        version: undefined,
        // 文件上传
        file: undefined,
        // 版本描述
        description: undefined,
        version: undefined,
      },
    };
  },
  mounted() {
    this.unpdata();
  },
  methods: {
    /** 查询下载列表 */
    unpdata() {
      delDashboard(this.queryParams).then((response) => {
        if (response.code == "200") {
          this.softName = response.data;
        } else {
          this.$message.error(response.msg);
        }
        this.loading = false;
      });
    },
    // 版本下载列表重置
    reset01() {
      this.form = {
        createBy: undefined,
        version: undefined,
        createTime: undefined,
        id: undefined,
        description: undefined,
      };
      this.checkList = [];
      this.resetForm("form");
    },
    handleMoos(row) {
      this.open = true;
      this.reset01();
      this.queryParams.softManageId = row.id;
      listVersion(this.queryParams).then((response) => {
        if (response.code == "200") {
          this.gridData = response.rows;
          this.total = response.total;
        } else {
          this.$message.error(response.msg);
        }
        this.loading = false;
      });
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.reset01();
      delDashboard(this.queryParams).then((response) => {
        if (response.code == "200") {
          this.gridData = response.rows;
          this.total = response.total;
        } else {
          this.$message.error(response.msg);
        }
        this.loading = false;
      });
    },
  },
};
</script>
<style scoped>
.box {
  flex: content;
  padding-top: 2%;
  text-align: center;
  font-size: 25px;
}
.el-input {
  width: 610px;
}
.bady {
  margin-top: 2%;
  text-align: center;
}
.bottn {
  display: flex;
  width: 100%;
  line-height: 100%;
}
.buttnLink {
  width: 35%;
  text-align: left;
  height: 160px;
  margin-left: 10%;
  margin-top: 2%;
  border: 1px solid #dcdfe6;
  border-width: 1px;
  padding: 10px;
}
.buttonRoom {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.left {
  justify-content: flex-start;
}
.right {
  justify-content: flex-end;
}
</style>
